home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Halves scroll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  3.0 KB  |  101 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define        BoxSize        10
  15. #define CorrectTime 3
  16.  
  17. void HalvesScroll(GrafPtr);
  18.  
  19. /* 2 regions, split down the middle of the screen.  Scroll the screen up in one
  20.    region and down in the other. */
  21.    
  22. void HalvesScroll(GrafPtr sourceGrafPtr)
  23. {
  24.     int            x;
  25.     Rect        theTopRect, topdest, theBottomRect, bottomdest;
  26.     Rect        topscrollsource, topscrolldest, bottomscrollsource, bottomscrolldest;
  27.     RgnHandle    toprgn,bottomrgn;
  28.     int            cx;
  29.     
  30.     cx = MAIN_WINDOW_WIDTH / 2;
  31.  
  32.     toprgn=NewRgn();
  33.     SetEmptyRgn(toprgn);
  34.     MoveTo(0,0);
  35.     OpenRgn();
  36.         Line(cx,0);
  37.         LineTo(cx,MAIN_WINDOW_HEIGHT);
  38.         LineTo(0,MAIN_WINDOW_HEIGHT);
  39.         LineTo(0,0);
  40.     CloseRgn(toprgn);
  41.     
  42.     bottomrgn=NewRgn();
  43.     SetEmptyRgn(bottomrgn);
  44.     MoveTo(cx,0);
  45.     OpenRgn();
  46.         LineTo(cx,MAIN_WINDOW_HEIGHT);
  47.         LineTo(MAIN_WINDOW_WIDTH,MAIN_WINDOW_HEIGHT);
  48.         LineTo(MAIN_WINDOW_WIDTH,0);
  49.         LineTo(cx,0);
  50.     CloseRgn(bottomrgn);
  51.     
  52.     topscrollsource=gMainWindow->portRect;
  53.     topscrollsource.bottom-=BoxSize;
  54.     topscrollsource.right=cx;
  55.     topscrolldest = topscrollsource;
  56.     OffsetRect(&topscrolldest, 0, BoxSize);
  57.     
  58.     topdest = gMainWindow->portRect;
  59.     topdest.bottom=BoxSize;
  60.     topdest.right=cx;
  61.     
  62.     theTopRect.top=MAIN_WINDOW_HEIGHT-BoxSize;
  63.     theTopRect.bottom=MAIN_WINDOW_HEIGHT;
  64.     theTopRect.left=0;
  65.     theTopRect.right=cx;
  66.     
  67.     bottomscrollsource=gMainWindow->portRect;
  68.     bottomscrollsource.top+=BoxSize;
  69.     bottomscrollsource.left=cx;
  70.     bottomscrolldest=bottomscrollsource;
  71.     OffsetRect(&bottomscrolldest, 0, -BoxSize);
  72.     
  73.     bottomdest=gMainWindow->portRect;
  74.     bottomdest.top=bottomdest.bottom-BoxSize;
  75.     bottomdest.left=cx;
  76.     
  77.     theBottomRect.top=0;
  78.     theBottomRect.bottom=BoxSize;
  79.     theBottomRect.left=cx;
  80.     theBottomRect.right=MAIN_WINDOW_WIDTH;
  81.     
  82.     for(x = MAIN_WINDOW_HEIGHT - BoxSize; x >= 0; x -= BoxSize)
  83.     {
  84.         StartTiming();
  85.         CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
  86.                 &topscrollsource, &topscrolldest, 0, toprgn);
  87.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  88.                 &theTopRect, &topdest, 0, toprgn);
  89.         theTopRect.bottom-=BoxSize;
  90.         theTopRect.top-=BoxSize;
  91.         
  92.         CopyBits(&(gMainWindow->portBits), &(gMainWindow->portBits),
  93.                 &bottomscrollsource, &bottomscrolldest, 0, bottomrgn);
  94.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  95.                 &theBottomRect, &bottomdest, 0, bottomrgn);
  96.         theBottomRect.top+=BoxSize;
  97.         theBottomRect.bottom+=BoxSize;
  98.         
  99.         TimeCorrection(CorrectTime);
  100.     }
  101. }